const _function = require("../../utils/functionData.js")
Page({
  data: {
    isRefreshing: false,
    isLoading: false,
    hasMore: true,
    page: 1,
    clubList: [
      // {
      //   id: 1,
      //   name: "科技创新社",
      //   description: "聚焦前沿科技探索，组织各类创新实践活动",
      //   memberCount: 256
      // }
    ]
  },
  onLoad(options) {
    this.getStudentSocietyList()
  },
  getStudentSocietyList() {
    const prams = {
      studentId: getApp().globalData.userInfo.userId
    }
    _function.getStudentSocietyList(prams, this.getStudentSocietyListBack, this)
  },
  getStudentSocietyListBack(res) {
    let dataAll = res.data
    if (dataAll.code == 200) {
      this.setData({
        clubList: dataAll.rows
      })

    }
  },
  // 下拉刷新
  onPullDownRefresh() {
    this.setData({ isRefreshing: true });
    // 模拟请求
    setTimeout(() => {
      this.setData({
        clubList: [...newData],
        isRefreshing: false,
        page: 1
      });
      wx.stopPullDownRefresh();
    }, 1500);
  },

  // 上拉加载
  loadMore() {
    if (!this.data.hasMore || this.data.isLoading) return;

    this.setData({ isLoading: true });
    // 模拟请求
    setTimeout(() => {
      this.setData({
        clubList: [...this.data.clubList, ...newData],
        page: this.data.page + 1,
        isLoading: false,
        hasMore: this.data.page < 3
      });
    }, 1000);
  }
});